import React, { Component } from 'react';
import './GoodsList.scss'
import {index_goodlist} from '../utils/api'

class GoodsList extends Component {
    constructor(props){
        super(props);
        this.state={
            arr1:[]
        }
    }

    componentDidMount(){
        index_goodlist({count:18}).then((res)=>{
            this.setState({arr1:res.data.list})
        })
    }
    render() {
        return (
            <div className='goodslist'>
                <header>
                    <div className='time'>
                        <span>今日值得买</span>
                        <span></span>
                    </div>
                    <span>MORE &gt;</span>
                </header>
                {
                    this.state.arr1.map((item,index)=>{
                        return(
                             <div className='card' key={index}>
                                <img src={item.pic} alt="" />
                                <span className='name'>{item.name}</span><br />
                                <span className='origin'>{item.activityTags}</span><br />
                                <i>抢购价￥</i><span className='price'>{item.salesPrice.value}</span>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default GoodsList;